﻿@model TextFolder

@if (Model != null)
{
    <div class="breadcrumb">
        @{var path = Model.NamePaths.ToArray();}
        <a href="@Url.Action("Index", new { controller = "TextFolder", repositoryName = ViewContext.RequestContext.GetRequestValue("repositoryName"), siteName = ViewContext.RequestContext.GetRequestValue("siteName") })">@("Text content")</a>
        @for (var i = 0; i < path.Length; i++)
        {
            var current = new TextFolder(Repository.Current, PageHelper.CombineFullName(path.Take(i + 1))).AsActual();
            if (current != null)
            {
                @Html.IconImage("arrow gray-right")
                if (i == path.Length - 1)
                {
                    <span>@current.FriendlyText@*@("(")<a href="@Url.Action("Edit", ViewContext.RequestContext.AllRouteValues().Merge("controller","TextFolder").Merge("UUID", Model.FullName).Merge("return", Request.RawUrl))">@("Edit".Localize())</a>@(")")*@</span>
                }
                else
                {
                    if (string.IsNullOrEmpty(current.SchemaName))
                    {
                        <a href="@Url.Action("Index", new { controller = "TextFolder", repositoryName = ViewContext.RequestContext.GetRequestValue("repositoryName"), siteName = ViewContext.RequestContext.GetRequestValue("siteName"), folderName = current.FullName })">@current.FriendlyText</a>
                    }
                    else
                    {
                        <a href="@Url.Action("Index", ViewContext.RequestContext.AllRouteValues().Merge("controller","TextContent").Merge("FolderName", @current.FullName))">@current.FriendlyText</a>
                    }
                }
            }
        }
    </div>
}